<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<style>
.invoices {
	width: 100%; padding-top : 10px;
	padding-bottom: 10px;
	border-top: 1px solid #dddddd;
	padding-top: 10px;
}
</style>

<c:if test="${!empty invoices}">

	<h1>Invoices</h1>

		<div class="row invoices">
			<div class="col-md-2"><b>Number</b></div>
			<div class="col-md-2"><b>Date Activation</b></div>
			<div class="col-md-2"><b>Sum</b></div>
			<div class="col-md-3"><b>Type Payment</b></div>
			<div class="col-md-2"><b>Status</b></div>
		</div>
		<c:forEach items="${invoices}" var="invoice">
			<div class="row invoices">
				<form method="post" action="invoices/replay">
					<div class="col-md-2">${invoice.id}
						<input type="hidden" value="${invoice.id}" name="invoice_id" />
					</div>
					<div class="col-md-2">
						<fmt:formatDate value="${invoice.dateActivation}"
							pattern=" MM-dd-yyyy" />
					</div>
					<div class="col-md-2">${invoice.sum}</div>

					<div class="col-md-3">
						<c:choose>
							<c:when test="${invoice.isReplay==true}">
						${invoice.typePayment.name}
						</c:when>
							<c:when test="${invoice.isReplay==false}">
								<select class="form-control" name="metodPayment">
									<option disabled selected="selected">Select payment
										method</option>
									<c:forEach items="${typePayments}" var="typePayment">
										<option value="${typePayment.id}">${typePayment.name}</option>
									</c:forEach>
								</select>
							</c:when>
						</c:choose>
					</div>

					<div class="col-md-2">
						<c:choose>
							<c:when test="${invoice.isReplay==false}">
								<input type="submit" class="btn btn-primary" value="Replay" />
							</c:when>
							<c:when test="${invoice.isReplay==true}">
						Reply
						</c:when>
						</c:choose>
					</div>
				</form>
			</div>

		</c:forEach>

</c:if>
<c:if test="${empty invoices}">
			<h3>No invoices</h3>
		</c:if>
